package io;

import java.util.Arrays;
import java.util.Objects;

public class Person implements java.io.Serializable{//该代码定义了一个名为Person的类，并且实现了java.io.Serializable接口。这意味着Person类的实例可以被序列化，即将对象的状态转换为字节序列，以便在网络上传输或存储
    private String name;
    private int age;
    private String gender;
    private transient String[] otherInfo;
    Person(){}
    Person(String name,int age,String gender,String[] otherInfo){
        this.name = name;
        this.age = age;
        this.gender = gender;
        this.otherInfo = otherInfo;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String[] getOtherInfo() {
        return otherInfo;
    }

    public void setOtherInfo(String[] otherInfo) {
        this.otherInfo = otherInfo;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", gender='" + gender + '\'' +
                ", otherInfo=" + Arrays.toString(otherInfo) +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Person person = (Person) o;
        return age == person.age && Objects.equals(name, person.name) && Objects.equals(gender, person.gender) && Objects.deepEquals(otherInfo, person.otherInfo);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age, gender, Arrays.hashCode(otherInfo));
    }
}
